<template>
  <!-- 问题分类页面 -->
  <div class="w100">
    <LibList
      v-for="(item, index) in state.questions"
      :key="index"
      :msg="item"
      @questino-detail="fnViewQuestion"
    />
  </div>
</template>

<script>
import { reactive } from "vue";
import LibList from "./LibList.vue";
import { post_ } from "/@/http/api.js";

export default {
  // 子组件
  components: {
    LibList,
  },
  // 父组件传值
  props: {
    msg: Object,
  },
  // 事件抛出组
  emits: ["question-detailm"],
  // 钩子
  setup(props, { emit }) {
    // 双向绑定数据
    const state = reactive({
      questions: [],
    });
    // 列表查询
    const fnGetList = (val) => {
      post_("api/getQuestions", {
        status: 1,
      }).then((res) => {
        state.questions = res;
      });
    };
    fnGetList();
    // 查看问题
    const fnViewQuestion = (val) => {
      emit("question-detailm", val);
    };
    // 传入模板
    return {
      state,
      fnViewQuestion,
    };
  },
};
</script>

<style scoped></style>
